<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
    String path = request.getContextPath();

    String basePath = request.getScheme() + "://" + request.getServerName() + ":"
                      + request.getServerPort() + path + "/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>新增文章</title>
<s:include value="../include.jsp"></s:include>
<link rel="stylesheet" type="text/css" href="../css/ztree/demo.css">
<link rel="stylesheet" type="text/css" href="<%=basePath%>css/ztree/zTreeStyle/zTreeStyle.css">
<script type="text/javascript" src="<%=basePath%>ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="<%=basePath%>js/ztree/jquery.ztree.core-3.3.js"></script>
<script type="text/javascript" src="<%=basePath%>js/address.js"></script>

<script type="text/javascript">	
	var setting = {
		view : {
			showIcon : showIconForTree
		},
		data : {
			simpleData : {
				enable : true
			}
		}
	};

	var zNodes = <s:text name="jsonArray"></s:text>

	function showIconForTree(treeId, treeNode) 
	{
		return !treeNode.isParent;
	};

	$(document).ready(function() 
	{
		$.fn.zTree.init($("#treeDemo"), setting, zNodes);
	});

	/**
	 * 保存
	 */
	function save() 
	{
		//检验父菜单
		var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
		var sNodes = treeObj.getSelectedNodes();
		if(sNodes.length == 0) 
		{
			alert("所属菜单是必选项");
			return;
		}

		var ids=new Array();
		//遍历
		for(var i=0;i<sNodes.length;i++)
		{
			ids[i] = sNodes[i].id;
		}
		document.getElementById("article.menu_ids").value = ids;
		
		//检验菜单名称
		var menuName = document.getElementById("article_title").value;
		menuName = trimVal(menuName);
		if (menuName == "") 
		{
			alert("文章标题是必填项");
			return;
		}
			
		//检验菜单排序
		var menuSort = document.getElementById("articleseq").value;
		if (menuSort != "") 
		{
			menuSort = trimVal(menuSort);
			if (isNaN(menuSort)) 
			{
				alert("文章排序必须是数字1-99");
				return;
			}
		} else 
		{
			alert("文章排序是必填项");
			return;
		}
		
		chgAction("paperAction", "save");
		document.forms[0].submit();
	}

	/**
	 * 返回
	 */
	function back() 
	{
		window.location = "paperAction.action";
	}
	<s:if test="operateResult=='suc'">
		alert("保存成功");
		window.location = "paperAction!query.action";
	</s:if>
	<s:if test="operateResult=='succ'">
		alert("导入成功");
		window.location = "paperAction!query.action";
	</s:if>
	<s:if test="operateResult=='faill'">
		alert("导入失败");
		window.location = "paperAction!query.action";
	</s:if>
	<s:elseif test="operateResult=='fail'">
		alert("保存失败");
	</s:elseif>
	
</script>
</head>

<body>
	<div class="outerDiv" style="height:500px;overflow-y: auto;">
		<s:form name="form1" action="paperAction" method="post">
			<s:hidden name="article.menu_ids" id="article.menu_ids"></s:hidden>
			<div class="top_box">
				您的位置：基础功能&gt;&gt;菜单信息管理&gt;&gt;<span class="red">新增文章</span>
			</div>
			
			<div class="form_list_box">
				<table width="100%">
					<tr>
						<td align="right"><font color="red">*</font>所属菜单：</td>
						<td>
							<div class="zTreeDemoBackground left" style="height: 250px">
								<ul id="treeDemo" class="ztree" style="height: 230px"></ul>
							</div></td>
					</tr>
					<tr>
						<td align="center" width="40%" colspan="2"><font color="red">（按住Ctrl可选中多个菜单）</font></td>
					</tr>
					<tr>
						<td align="right" width="40%"><font color="red">*</font>文章标题：</td>
						<td align="left"><s:textfield name="article.article_title"
								id="article_title" maxlength="25"></s:textfield>
						</td>
					</tr>
					<tr>
						<td align="right" width="40%"><font color="red">*</font>文章类别：</td>
						<td align="left">
							<s:radio list="#{0:'不可评论 ',1:'可评论 '}" name="article.article_type" id="article_type" value="1"></s:radio>
						</td>
					</tr>
					<tr>
						<td align="right" width="40%"><font color="red">*</font>文章排序：</td>
						<td align="left">
							<s:textfield name="article.articleseq"
								id="articleseq" maxlength="2"></s:textfield>
						</td>
					</tr>
					<tr>
						<td align="right" width="40%"><font color="red">*</font>机构名称：</td>
						<td align="left">
							<s:textfield name="article.ORG_NAME"
								id="ORG_NAME"></s:textfield>
						</td>
					</tr>
					<tr>
						<td align="right" width="40%"><font color="red">*</font>联系人：</td>
						<td align="left">
							<s:textfield name="article.course_contacts"
								id="COURSE_CONTACTS"></s:textfield>
						</td>
					</tr>
					<tr>
						<td align="right" width="40%"><font color="red">*</font>电话：</td>
						<td align="left">
							<s:textfield name="article.tel"
								id="TEL"></s:textfield>
						</td>
					</tr>
					<tr>
						<td align="right" width="40%"><font color="red">*</font>其他电话：</td>
						<td align="left">
							<s:textfield name="article.tel_other"
								id="TEL_OTHER"></s:textfield>
						</td>
					</tr>
					<tr>
						<td align="right" width="40%"><font color="red">*</font>地区：</td>
						<td align="left">
							<select onchange="city1(this.value)" name="article.area_s">
								<option value="00">请选择</option>
								<option value="01">江岸</option>
								<option value="02">江汉</option>
								<option value="03">硚口</option>
					            <option value="04">汉阳</option>
					            <option value="05">武昌</option>
					            <option value="06">青山</option>
					            <option value="07">洪山</option>
					            <option value="08">东西湖</option>
					            <option value="09">汉南</option>
					            <option value="10">江夏 </option>
					            <option value="11">蔡甸</option>
					            <option value="12">黄陂</option>
					            <option value="13">新洲 </option>
							</select>
							<select id="city" name="article.area_e">
								<option value="00">请选择</option>
							</select>
						</td>
					</tr>
					<tr>
						<td align="right" width="40%"><font color="red">*</font>详细地址：</td>
						<td align="left">
							<s:textfield name="article.course_address"
								id="COURSE_ADDRESS"></s:textfield>
						</td>
					</tr>
					<tr>
						<td align="right" width="40%"><font color="red">*</font>上课方式：</td>
						<td align="left">
							<s:radio list="#{0:'家教 ',1:'一对一 ',2:'辅导班 ',3:'网络教学 ',4:'面议'}" name="article.course_type" id="COURSE_TYPE" value="0"></s:radio>
						</td>
					</tr>
					<tr>
						<td align="right" width="40%"><font color="red">*</font>开课时间：</td>
						<td align="left">
							<s:radio list="#{0:'随到随学 ',1:'一周内 ',2:'两周内 ',3:'一月内 ',4:'上课中',5:'已结束'}" name="article.time_type" id="TIME_TYPE" value="0"></s:radio>
						</td>
					</tr>
					<tr>
						<td align="right" width="40%"><font color="red">*</font>上课时间：</td>
						<td align="left">
							<s:checkboxlist list="#{0:'星期一 ',1:'星期二 ',2:'星期三 ',3:'星期四 ',4:'星期五 ',5:'星期六 ',6:'星期日 '}" id="COURSE_WEEK" name="article.COURSE_WEEK" value="0"/><br>
							<s:checkboxlist list="#{0:'上午',1:'下午',2:'晚上'}" id="COURSE_TIME" name="article.course_time" value="0"/>
						</td>
					</tr>
					<tr>
						<td align="right" width="40%"><font color="red">*</font>收费标准：</td>
						<td align="left">
							<s:radio list="#{0:'面议 ',1:'1000元以下 ',2:'1001元-2500元 ',3:'2501元-5000元 ',4:'5000元以上 '}" name="article.course_fee" id="COURSE_FEE" value="0"></s:radio>
						</td>
					</tr>
					<tr>
						<td align="right" width="40%"><font color="red">*</font>图片：</td>
						<td align="left">
							<s:textfield name="article.pic_link"
								id="PIC_LINK"></s:textfield>
						</td>
					</tr>
					<tr><td>&nbsp;</td></tr>
					<tr><td align="right" colspan="2" width="1020">
					<textarea  cols="80" id="editor1" name="article.article_content" rows="10">
					      在此添加内容
					 </textarea>
					 <script type="text/javascript">
					    CKEDITOR.replace( 'editor1',
					     {
					      skin : 'kama',
					      language : 'zh-cn'
					     });
					 </script>
					 </td></tr>
				</table>
				<div class="btn_box">
					<a href="#" onclick="save()"><s></s>保存</a> <a href="#"
						onclick="back()"><s></s>返回</a>
				</div>
			</div>
		</s:form>
	</div>
</body>
</html>